﻿
CREATE PROCEDURE [dbo].[proc_Company_Delete]
	(
		--@Id nvarchar(MAX)
		@id INT
	)
AS
	begin tran
		--EXEC('Delete From Company Where Id in ('+@Id+')')
		--EXEC('Delete From Company_Range Where CompanyId in ('+@Id+')')	
		
		DELETE FROM Company WHERE id=@id
		DELETE FROM Company_Range WHERE CompanyId=@id
		
		DELETE FROM ManagementArea WHERE zid=(SELECT bh FROM zzjg z WHERE z.CompanyId=@id)
		DELETE FROM zzjg WHERE CompanyId=@id	
		
	commit tran
	RETURN